#include<bits/stdc++.h>
using namespace std;
int64_t t,n,m,L,V,d[100005],v0[100005],a[100005],p[100005],need[100005],over[100005],p_[100005],m_,ai_all0=1,tot;
bool overspeed(int id1,int id2=0){
	if(id2==0){
		if(a[id1]>=0)return overspeed(id1,m);
		else return overspeed(id1,lower_bound(p+1,p+m+1,d[id1])-p);
	}else if(d[id1]>p[id2])return 0;
	else return v0[id1]*v0[id1]+2*a[id1]*(p[id2]-d[id1])>V*V;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--){
		cin>>n>>m>>L>>V;
		tot=0,ai_all0=1;
		for(int i=1;i<100005;i++)
			d[i]=v0[i]=a[i]=p[i]=need[i]=0;
		for(int i=1;i<=n;i++){
			cin>>d[i]>>v0[i]>>a[i];
			if(a[i]!=0)ai_all0=0;
		}
		for(int i=1;i<=m;i++)cin>>p[i];
		for(int i=1;i<=n;i++)over[i]=overspeed(i),tot+=over[i];
		cout<<tot<<' ';
		if(ai_all0){
			cout<<(tot>0?m-1:m)<<'\n';
			continue;
		}
	}
	return 0;
}
